package response

type Status struct {
	Code    int64
	Message string
}

var statusMessageCode = map[int64]Status{
	SuccessCode:      {Code: SuccessCode, Message: "成功"},
	FailedCode:       {Code: FailedCode, Message: "失败"},
	UnauthorizedCode: {Code: UnauthorizedCode, Message: "未授权"},

	SystemParameterErrorCode: {Code: SystemParameterErrorCode, Message: "参数有误，请检查请求参数"},
	SystemPermissionCode:     {Code: SystemPermissionCode, Message: "权限不足"},

	GetCaptchaFailedCode: {Code: GetCaptchaFailedCode, Message: "验证码获取失败"},
	CaptchaVerifiedCode:  {Code: CaptchaVerifiedCode, Message: "验证成功"},
	CaptchaInvalidCode:   {Code: CaptchaInvalidCode, Message: "验证码无效"},

	UserNotFoundCode:                {Code: UserNotFoundCode, Message: "用户不存在"},
	UserRegistrationFailedCode:      {Code: UserRegistrationFailedCode, Message: "注册失败"},
	UserAccountExistsCode:           {Code: UserAccountExistsCode, Message: "账号已存在"},
	UserNameExistsCode:              {Code: UserNameExistsCode, Message: "用户名已存在"},
	UserLoginSuccessCode:            {Code: UserLoginSuccessCode, Message: "登录成功"},
	UserLoginFailedCode:             {Code: UserLoginFailedCode, Message: "登录失败"},
	UserAccountOrPasswordFailedCode: {Code: UserAccountOrPasswordFailedCode, Message: "账号或密码错误"},
	UserModifyInfoFailedCode:        {Code: UserModifyInfoFailedCode, Message: "更新用户信息失败"},
	UserUnauthorizedCode:            {Code: UserUnauthorizedCode, Message: "未授权"},
	UserPermissionDeniedCode:        {Code: UserPermissionDeniedCode, Message: "权限不足"},
	UserAccountLockedCode:           {Code: UserAccountLockedCode, Message: "用户被禁用"},

	RoleNotFoundCode: {Code: RoleNotFoundCode, Message: "角色不存在"},
	RoleExistsCode:   {Code: RoleExistsCode, Message: "角色已经存在"},

	UserRoleNotFoundCode: {Code: UserRoleNotFoundCode, Message: "用户角色关系不存在"},
	UserRoleExistsCode:   {Code: UserRoleExistsCode, Message: "用户角色关系已存在"},

	MenuParameterErrorCode:   {Code: MenuParameterErrorCode, Message: "菜单模块请求参数错误"},
	MenuNotFoundCode:         {Code: MenuNotFoundCode, Message: "菜单信息不存在"},
	MenuExistsCode:           {Code: MenuExistsCode, Message: "菜单信息已经存在"},
	MenuParentIdNotEmptyCode: {Code: MenuParentIdNotEmptyCode, Message: "父级菜单ID不能为空"},
	MenuParentNotFoundCode:   {Code: MenuParentNotFoundCode, Message: "父级菜单不存在"},
	MenuLevelErrorCode:       {Code: MenuLevelErrorCode, Message: "菜单层级错误"},
	MenuDeleteCode:           {Code: MenuDeleteCode, Message: "删除菜单信息失败"},

	RoleMenuNotFoundCode: {Code: RoleMenuNotFoundCode, Message: "角色菜单关系不存在"},
	RoleMenuExistsCode:   {Code: RoleMenuExistsCode, Message: "角色菜单关系已存在"},
}

func GetStatusCode(code int64) Status {
	status, exists := statusMessageCode[code]
	if !exists {
		return Status{
			Code:    code,
			Message: "未知错误",
		}
	}
	return status
}
